package com.topc.others.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.topc.base.exception.Asserts;
import com.topc.others.mapper.ArticleCommentInfoMapper;
import com.topc.others.model.dto.SaveArticleCommentDto;
import com.topc.others.model.po.ArticleCommentInfo;

import com.topc.others.service.IArticleCommentInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 文章评论信息 服务实现类
 * </p>
 *
 * @author Gogoing
 */
@Slf4j
@Service
public class ArticleCommentInfoServiceImpl extends ServiceImpl<ArticleCommentInfoMapper, ArticleCommentInfo> implements IArticleCommentInfoService {

    @Override
    public void saveCommentInfo(SaveArticleCommentDto saveArticleCommentDto) {
        ArticleCommentInfo articleCommentInfo = new ArticleCommentInfo();
        BeanUtil.copyProperties(saveArticleCommentDto, articleCommentInfo);
        boolean save = this.save(articleCommentInfo);
        if (!save)Asserts.fail("评论失败");
    }

    @Override
    public void deleteCommentInfoById(Long id) {
        boolean remove = this.removeById(id);
        if (!remove) Asserts.fail("删除失败");
    }
}
